package LopCoBan;

import java.util.ArrayList;
import java.util.Date;

import com.db4o.ObjectContainer;

public class CaTruc {
	private String TenCa;
	private Date NgayTruc;	
	private float GioBatDau;
	private float GioKetThuc;
	private ArrayList<NhanVien> mNhanVien;

	public CaTruc() {
		
	}

	public CaTruc(Date d_val, float bd_val, float kt_val) {
		NgayTruc = d_val;
		GioBatDau = bd_val;
		GioKetThuc = kt_val;
		mNhanVien = new ArrayList<NhanVien>();
	}

	public CaTruc(Date d_val, float bd_val, float kt_val,
	ArrayList<NhanVien> nv_val) {
		NgayTruc = d_val;
		GioBatDau = bd_val;
		GioKetThuc = kt_val;
		mNhanVien = nv_val;
	}

	public float getGioBatDau() {
		return GioBatDau;
	}

	public void setGioBatDauKetThuc(float gioBD,float gioKT) {
		this.GioBatDau = gioBD;
		this.GioKetThuc=gioKT;
	}

	public float getGioKetThuc() {
		return GioKetThuc;
	}


	public Date getNgayTruc() {
		return NgayTruc;
	}

	public void setNgayTruc(Date val) {
		this.NgayTruc = val;
	}

	public ArrayList<NhanVien> getNhanVien() {
		return mNhanVien;
	}

	public void setNhanVien(ArrayList<NhanVien> val) {
		this.mNhanVien = val;
	}

	public boolean addCaTruc(NhanVien val) {
		for (NhanVien ct : mNhanVien) {
			if (val.equals(ct))
				return false;
		}
		mNhanVien.add(val);
		return true;
	}

	public void save(ObjectContainer db) {
		db.store(this);
	}

	public boolean nhanvienTruc(String manv, Date tu, Date den) {
		for (NhanVien ct : mNhanVien) {
			if (manv.equals(ct.getMaNV()) && NgayTruc.after(tu)
					&& NgayTruc.before(den))
				return true;
		}
		return false;

	}
}
